<!--
    设备明细
 -->
<template>
    <div class="page">
        <div class="nuclein-query">
            <div>设备明细</div>
            <div style="margin-left: auto;">
                <!-- <el-button type="primary" @click="handlerAdd()">添加</el-button> -->
            </div>
        </div>
        <div class="device-type">
            <p>
                <span>设备类型：</span>
                <el-select v-model="type" placeholder="请选择" @change="handlerChange" clearable>
                    <el-option v-for="item in deviceLogType" :key="item.value" :label="item.label" :value="item.value">
                    </el-option>
                </el-select>
            </p>
        </div>
        <div class="content-row">
            <el-table :data="tableData" style="width: 100%" border>
                <el-table-column property="deviceName" label="设备名称"></el-table-column>
                <el-table-column property="createTime" label="设备型号"></el-table-column>
                <el-table-column property="deviceSn" label="设备所在小区"></el-table-column>
                <el-table-column property="deviceSn" label="设备所在点位"></el-table-column>
                <el-table-column property="deviceSite" label="设备数量"></el-table-column>
                <el-table-column property="deviceSite" label="单位"></el-table-column>
                <el-table-column property="deviceSn" label="单价"></el-table-column>
                <el-table-column property="deviceSn" label="设备金额"></el-table-column>
                <el-table-column label="操作" align="center" width="160">
                    <template slot-scope="scope">
                        <el-button page="succes" @click="handleQuery(scope.$index, scope.row)">查看详情</el-button>
                    </template>
                </el-table-column>
            </el-table>
        </div>
        <!-- // 分页 -->
        <div class="pagination">
            <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="page"
                :page-sizes="[10, 20, 30, 40]" :page-size="size" layout="total, sizes, prev, pager, next, jumper"
                :total="total">
            </el-pagination>
        </div>
    </div>
</template>

<script>
import { management, getOneList } from '../../api/api'
import commonFunction from '../../utils/commonFunction'
import commonData from '../../utils/commonData'
export default {

  data () {
    return {
      deviceLogType: commonData.deviceLogType,
      total: 10,
      page: 1,
      size: 10,
      tableData: [],
      type: ''
    }
  },
  created () {
    this.gitList()
  },
  methods: {
    // 获取
    gitList () {
      const data = {
        type: this.type,
        page: this.page,
        size: this.size
      }
      management({ ...data }).then(res => {
        if (res.code == 0) {
          const { records, total } = res.page
          this.total = total
          this.tableData = records
        } else {
          this.$message.error(res.msg)
        }
      })
    },
    handlerChange (e) {
      this.type = e
      this.gitList()
    },

    // 分页
    handleSizeChange (val) {
      this.size = val
      this.gitList()
    },
    handleCurrentChange (val) {
      this.page = val
      this.gitList()
    }
  }
}
</script>

<style scoped>
.page {
    height: 100%;
}

.nuclein-query {
    display: flex;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #DCDFE6;
}

.content-row {
    overflow: hidden;
}

.device-type {
    padding: 20px 20px 10px 20px;
}

/* 分页 */
.pagination {
    width: 100%;
    padding: 20px;
    border-top: 1px solid #DCDFE6;
}

.drawer-table {
    padding: 20px;
}
</style>
